package org.irri.smta.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SystemUtils {

	private static final Logger LOGGER = LoggerFactory
			.getLogger(SystemUtils.class);

	public static void logMemoryStats() {
		Integer MBYTES = 1024 * 1024;

		// Getting the runtime reference from system
		Runtime runtime = Runtime.getRuntime();

		LOGGER.debug("===== Memory Utilization Statistics (Megabytes) =====");

		// Log used memory
		LOGGER.debug("Used Memory: "
				+ (runtime.totalMemory() - runtime.freeMemory()) / MBYTES);

		// Log free memory
		LOGGER.debug("Free Memory: " + runtime.freeMemory() / MBYTES);

		// Log total available memory
		LOGGER.debug("Total Memory: " + runtime.totalMemory() / MBYTES);

		// Log maximum available memory
		LOGGER.debug("Max Memory: " + runtime.maxMemory() / MBYTES);
	}

}
